<?php
class indexController {
    public $controller;

    public function __construct() {
        $this -> controller = null;
    }

    public function invoke() {
       
        $view = $_GET['view'];
        $script = explode('/', $_SERVER['SCRIPT_NAME']);
        $script = $script[count($script) - 1];
        if ($script == 'index.php') {
            
            switch($view) {
                case 'home' :
                    include_once ("controller/accountController.php");
                    $this -> controller = new accountController();
                    break;

                case 'product' :
                    include_once ("controller/productController.php");
                    $this -> controller = new productController();
                    $this -> controller -> invoke();
                    break;

                default :
                    include_once ("controller/productController.php");
                    $this -> controller = new productController();
                    $this -> controller -> invoke();
                    break;
            }
        } elseif ($script == 'admin.php') {
            switch($view) {
                case 'account' :
                    include_once ("controller/admin/accountController.php");
                    $this -> controller = new accountController();
                    $this -> controller -> invoke();
                    break;

                case "product" :
                    include_once ("controller/admin/productController.php");
                    $this -> controller = new productController();
                    $this -> controller -> invoke();
                    break;
            }

        } elseif ($script == 'cart.php') {

        } elseif ($script == 'account.php') {           
            include_once 'controller/accountController.php';
            $this -> controller = new accountController();
            $this -> controller -> invoke();
        }

    }

}
?>